home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 April / macformat-049.iso / mac / Shareware Plus / Developers / pipes ƒ / pipe.c next >
Encoding:
C/C++ Source or Header  |  1996-12-30  |  682 b   |  33 lines  |  [TEXT/CWIE]

  1. /*    pipe.c -- A portable implementation of a simple pipe
  2.  *    mechanism.
  3.  *
  4.  *    (c) 1997 Brian Connors. This code may be used for any 
  5.  *    purpose, by anyone, as long as you make available a 
  6.  *    copy of or equivalent cash value to the final product.
  7.  */
  8.  
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include "pipe.h"
  12.  
  13. /* popen: opens a pipe named fn as mode. The pipe is actually
  14.  *    just an ordinary file. If you pass in a null string, it 
  15.  *    looks around for a file called "stdout".
  16.  */
  17.  
  18. FILE *popen(const char *fn, const char *mode) {
  19.     FILE *pf;
  20.     
  21.     if (!fn) {
  22.         pf = fopen("stdout", mode);
  23.     } else {
  24.         pf = fopen(fn, mode);
  25.     }
  26.     
  27.     return pf;
  28. }
  29.  
  30. int pclose(FILE *pf) {
  31.     return fclose(pf);
  32. }
  33.